package cn.enjoy.design.behavior.strategy.springAutowired.controller;

import cn.enjoy.design.behavior.strategy.springAutowired.service.Animal;
import cn.enjoy.tool.utils.StringUtil;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @author K
 * @date 2023-06-30 17:08
 */
@RestController
public class AutowiredController {

    @Resource
    private Map<String, Animal> animalMap;

    @GetMapping("greet")
    public void greet(String type) {
        if (StringUtil.isBlank(type)) {
            type = "dog";
        }
        animalMap.get(type).greet();
    }

}
